/*
 * 版权所有 (C) 2015 知启蒙(ZHIQIM) 保留所有权利。
 * 
 * 欢迎到知启蒙网站（https://www.zhiqim.com）购买正版软件，知启蒙还提供许多开源框架和软件。
 * 
 * 1、本软件产品所有源代码受《中华人民共和国著作权法》和其他有关法律、法规的保护，其所有知识产权归湖南知启蒙科技有限公司所有；
 * 2、禁止复制和修改。不得复制修改、翻译或改编本软件所有源代码，或者基于本软件产品创作衍生作品；
 * 3、禁止进行逆向工程。不得对本软件的源代码进行逆向工程、反编译或试图以其他方式发现软件的源代码；
 * 4、个别授权：如需进行商业性的销售、复制、分发，包括但不限于软件销售、预装、捆绑等，必须获得知启蒙的书面授权和许可；
 * 5、保留权利：本注释未明示授权的其他一切权利仍归知启蒙所有，任何人使用其他权利时必须获得知启蒙的书面同意。
*/
package net.redxyz.repost.resource.model;

import org.zhiqim.kernel.util.Maths;

/**
 * 宝贝下架时间分布模型
 *
 * @version v7.0.1 @author zouzhigang 2021-7-30 新建与整理
 */
public class ItemDelistInfo
{
    private String hour;

    private int mon;
    private int tue;
    private int wed;
    private int thu;
    private int fir;
    private int sat;
    private int sun;

    private int totalAll;

    public ItemDelistInfo(String hour)
    {
        this.hour = hour;
    }

    public void setTotalAll(int totalAll)
    {
        this.totalAll = totalAll;
    }

    public String getHour()
    {
        return hour;
    }

    public void setHour(String hour)
    {
        this.hour = hour;
    }

    public int getMon()
    {
        return mon;
    }

    public void setMon(int mon)
    {
        this.mon = mon;
    }

    public int getTue()
    {
        return tue;
    }

    public void setTue(int tue)
    {
        this.tue = tue;
    }

    public int getWed()
    {
        return wed;
    }

    public void setWed(int wed)
    {
        this.wed = wed;
    }

    public int getThu()
    {
        return thu;
    }

    public void setThu(int thu)
    {
        this.thu = thu;
    }

    public int getFir()
    {
        return fir;
    }

    public void setFir(int fir)
    {
        this.fir = fir;
    }

    public int getSat()
    {
        return sat;
    }

    public void setSat(int sat)
    {
        this.sat = sat;
    }

    public int getSun()
    {
        return sun;
    }

    public void setSun(int sun)
    {
        this.sun = sun;
    }

    public String getTime()
    {
        if ("总计".equals(hour))
            return hour;

        return hour + ":00~" + hour + ":59";
    }

    public int getTotal()
    {
        return (mon + tue + wed + thu + fir + sat + sun);
    }

    public boolean hasData()
    {
        return getTotal() > 0;
    }

    public void addData(int week)
    {
        switch (week)
        {
        case 1:
            mon++;
            break;
        case 2:
            tue++;
            break;
        case 3:
            wed++;
            break;
        case 4:
            thu++;
            break;
        case 5:
            fir++;
            break;
        case 6:
            sat++;
            break;
        case 7:
            sun++;
            break;
        }
    }

    public String getMonAge()
    {
        return Maths.division(mon * 100, totalAll, 2) + "%";
    }

    public String getTueAge()
    {
        return Maths.division(tue * 100, totalAll, 2) + "%";
    }

    public String getWedAge()
    {
        return Maths.division(wed * 100, totalAll, 2) + "%";
    }

    public String getThuAge()
    {
        return Maths.division(thu * 100, totalAll, 2) + "%";
    }

    public String getFirAge()
    {
        return Maths.division(fir * 100, totalAll, 2) + "%";
    }

    public String getSatAge()
    {
        return Maths.division(sat * 100, totalAll, 2) + "%";
    }

    public String getSunAge()
    {
        return Maths.division(sun * 100, totalAll, 2) + "%";
    }

    public String getTotalAge()
    {
        return Maths.division(getTotal() * 100, totalAll, 2) + "%";
    }

    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((hour == null) ? 0 : hour.hashCode());
        return result;
    }

    public boolean equals(Object obj)
    {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        ItemDelistInfo other = (ItemDelistInfo) obj;
        if (hour == null)
        {
            if (other.hour != null)
                return false;
        }
        else if (!hour.equals(other.hour))
            return false;
        return true;
    }
}
